package API.AboutTime.CalendarAPI;

import java.util.Date;
import java.util.Calendar;

public class Basis {
    public static void main(String[] args) {
        //获取Calendar对象
        Calendar cal = Calendar.getInstance();
        //输出cal对象相应值
        System.out.println(cal);
        //输出cal对应的Date对象内容
        System.out.println(cal.getTime());
        //根据传入的Date对象修改cal对象
        cal.setTime(new Date(0L));
        //输出相应数据
        System.out.println(cal.getTime());
        System.out.println(cal.get(Calendar.YEAR) + " " + cal.get(Calendar.MONTH) + " " + cal.get(Calendar.DAY_OF_MONTH));
        //修改数据
        cal.set(Calendar.YEAR, 2024);//直接修改
        System.out.println(cal.get(Calendar.YEAR));
        cal.add(Calendar.YEAR, -1);//通过加减修改
        System.out.println(cal.get(Calendar.YEAR));
    }
}
